package com.example.recyclerviewdemo;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.recyclerviewdemo.bean.BasicBean;
import com.google.android.material.appbar.MaterialToolbar;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author : dushaohui
 * @Time : on 2024/3/13 9:27
 * @Description : BaseActivity
 *      基类
 */
public class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    /**
     * 返回
     * @param materialToolbar
     */
    protected void back(MaterialToolbar materialToolbar){
        materialToolbar.setNavigationOnClickListener(v->onBackPressed());
    }

    /**
     * 跳转
     * @param clazz
     */
    protected void intentActivity(final Class<?> clazz){
        startActivity(new Intent(this,clazz));
    }

    /**
     * 吐司
     * @param msg
     */
    protected void showMsg(CharSequence msg){
        Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();
    }

    /**
     * 获取字符串列表
     */
    protected List<String> getStrings(){
        List<String> lists = new ArrayList<>();
        // 1 - 41之间的随机数
        int num = (int) ((1+Math.random()) * (50 - 10 + 1));
        for (int i = 0; i < num; i++) {
            lists.add("第" + i + "条数据");
        }
        return  lists;
    }

    protected List<BasicBean> getBasicBean(){
        List<BasicBean> lists = new ArrayList<>();
        int num = (int) ((1+Math.random()) * (50-10+1));
        for (int i = 0; i < num; i++) {
            lists.add(new BasicBean("第" + i + "条标题","第" + i + "条内容"));
        }
        return  lists;
    }
}
